package com.cloudfun.campusshare.entity;

import com.cloudfun.campusshare.common.constant.CashAdvanceHandleType;
import com.cloudfun.campusshare.common.constant.CashAdvanceStatus;
import com.cloudfun.campusshare.common.constant.PayPlatform;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.GenericGenerator;

import javax.persistence.*;
import java.time.LocalDate;
import java.time.LocalDateTime;

/**
 * @author : zhangyongjie
 * @version : 1.0
 * @createTime : 2020/6/1 20:19
 * @description :
 */
@Data
@Entity
@NoArgsConstructor
@AllArgsConstructor
@Builder
@Table(name = "cash_advance")
public class CashAdvanceEntity extends CreatorPersistenceEntity implements Cloneable {
    @Id
    @GenericGenerator(name = "id_uuid", strategy = "uuid")
    @GeneratedValue(generator = "id_uuid")
    @Column(name = "id", unique = true, columnDefinition = ("varchar(40) not null comment '主键uuid'"))
    private String id;

    @Column(name = "cash_advance_no", unique = true, columnDefinition = ("varchar(32) not null comment '提现单号'"))
    private String cashAdvanceNo;

    @Column(name = "total_amount", columnDefinition = ("int(10) default 0 comment '提现总额'"))
    private Integer totalAmount;

    @Column(name = "total_discount_amount", columnDefinition = ("int(10) default 0 comment '卡券抵扣总额'"))
    private Integer totalDiscountAmount;

    @Column(name = "total_handing_fee", columnDefinition = ("int(10) default 0 comment '手续费总额'"))
    private Integer totalHandingFee;

    @Column(name = "total_settlement_amount", columnDefinition = ("int(10) default 0 comment '结算总额'"))
    private Integer totalSettlementAmount;

    @Column(name = "expect_amount", columnDefinition = ("int(10) default 0 comment '预计到账'"))
    private Integer expectAmount;

    @Column(name = "status", columnDefinition = ("varchar(32) not null comment '状态'"))
    @Enumerated(EnumType.STRING)
    private CashAdvanceStatus status;

    @Column(name = "launch_time", columnDefinition = ("datetime default null comment '发起时间'"))
    private LocalDateTime launchTime;

    @Column(name = "merchant_id", columnDefinition = ("varchar(40) not null comment '商家id'"))
    private String merchantId;

    @Column(name = "belong_merchant_name", columnDefinition = ("varchar(64) not null comment '所属商家名称'"))
    private String belongMerchantName;

    @Column(name = "begin_time", columnDefinition = ("date default null comment '提现（范围）开始时间'"))
    private LocalDate beginTime;

    @Column(name = "end_time", columnDefinition = ("date default null comment '提现（范围）结束时间'"))
    private LocalDate endTime;


    @Column(name = "bank_account", columnDefinition = ("varchar(40) default null comment '银行账户名称'"))
    private String bankAccount;

    @Column(name = "bank_account_name", columnDefinition = ("varchar(40) default null comment '银行账号'"))
    private String bankAccountName;

    @Column(name = "bank_name", columnDefinition = ("varchar(64) default null comment '开户银行'"))
    private String bankName;

    @Column(name = "deposit_position", columnDefinition = ("varchar(64) default null comment '开户省市'"))
    private String depositPosition;

    @Column(name = "belong_fork_bank", columnDefinition = ("varchar(64) default null comment '所属支行'"))
    private String belongForkBank;


    @Column(name = "transactor_id", columnDefinition = ("varchar(40) default null comment '处理人id'"))
    private String transactorId;

    @Column(name = "transactor_name", columnDefinition = ("varchar(40) default null comment '处理人用户名'"))
    private String transactorName;

    @Column(name = "handle_result", columnDefinition = ("varchar(40) default null comment '处理结果'"))
    @Enumerated(EnumType.STRING)
    private CashAdvanceHandleType handleResult;

    @Column(name = "handle_time", columnDefinition = ("datetime default null comment '处理时间'"))
    private LocalDateTime handleTime;

    @Column(name = "description", columnDefinition = ("varchar(255) default null comment '处理说明'"))
    private String description;

    @Enumerated(EnumType.STRING)
    @Column(name = "pay_platform", columnDefinition = ("varchar(30) default null comment '支付渠道'"))
    private PayPlatform payPlatform;

    public CashAdvanceEntity clone() {
        CashAdvanceEntity entity = null;
        try {
            entity = (CashAdvanceEntity) super.clone();
        } catch (CloneNotSupportedException e) {
            e.printStackTrace();
        }
        return entity;
    }
}
